using System;
using System.Collections.Generic;
using System.Text;
using SubSonic;

namespace MyCityCab.Core
{
    public partial class RegionController
    {
        public RegionCollection SearchRegions(string prefix, int countryId, int limit)
        {
            RegionCollection regionColl = new RegionCollection();
            Query query = Region.CreateQuery();
            query.Top = limit.ToString();
            query.WHERE(Region.Columns.CountryId, countryId);
            query.AND(Region.Columns.EnglishName, Comparison.Like, "%" + prefix + "%");
            regionColl.LoadAndCloseReader(query.ExecuteReader());
            return regionColl;
        }
    }
}
